using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using sbMembership.Library.Presenters.ViewInterfaces;
using sbMembership.Library.Presenters;
using sbMembership.Library.Domain;

namespace sbMembership.Web.Views
{

    public partial class AddUserView : System.Web.UI.UserControl, IAddUserView
    {
        AddUserPresenter presenter;

        public void AttachPresenter(AddUserPresenter presenter)
        {
            this.presenter = presenter;
        }

        public string Message
        {
            set { lblMessage.Text = value; }
        }

        public sbUser UserToAdd
        {
            get
            {
                sbUser retval = new sbUser(txtUsername.Text, txtPassword.Text, txtEmail.Text);
                return retval;
            }
        }

        public void ResetForm()
        {
            txtUsername.Text = string.Empty;
            txtPassword.Text = string.Empty;
            txtPassword2.Text = string.Empty;
            txtEmail.Text = string.Empty;
            ScriptManager.GetCurrent(this.Page).SetFocus(txtUsername);
        }

        protected void Page_Load(object sender, EventArgs e)
        {

        }
        protected void btnAddUserOK_Click(object sender, EventArgs e)
        {
            Page.Validate("AddUser");
            presenter.AddUser(Page.IsValid);
        }
    }
}